import React,{Suspense} from 'react'
import {
    BrowserRouter,
    Routes,
    Route,
    Navigate
} from 'react-router-dom'
import routes from './RouterConfig'
function index() {
    const rernderRouter = (arr) =>{
        return arr.map((item,index)=>{
            return item.path?<Route key={index} path={item.path} element={<item.element/>}>
                {
                    item.children&&rernderRouter(item.children)
                }
            </Route>
            :<Route key={index} path={item.from} element={<Navigate to={item.to}/>}></Route>
        })
    }
  return (
    <Suspense fallback={<div>正在跳转...</div>}>
        <BrowserRouter>
            <Routes>
                {
                    rernderRouter(routes)
                }
            </Routes>
        </BrowserRouter>
    </Suspense>
  )
}

export default index